﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using Utils;
public partial class forum_aspublic : FBasePage
{
    // Fields
    public string ASNzY = "";
    public List<Maticsoft.Model.topic> bbslist = new List<Maticsoft.Model.topic>();
    public string bbsname = "";
    public bool falg = false;
    public string pagenum = "1";
    public string strpage;

    // Methods
    public void Get_Bbs()
    {
        int num;
        Maticsoft.BLL.topic topic = new Maticsoft.BLL.topic();
        string whereString = "Parent_id=0  and  Zone='public' and Category.Id=topic.Public_id";
        if ((base.Request["ASNzY"] != null) && (base.Request["ASNzY"] != ""))
        {
            if (Utility.IsNum(base.Request["ASNzY"].ToString()))
            {
                whereString = whereString + " and Public_id=" + Convert.ToInt32(base.Request["ASNzY"]);
                this.ASNzY = base.Request["ASNzY"].ToString();
            }
            else
            {
                this.SetError("您输入的参数非法");
            }
        }
        this.bbslist = topic.Searchtopic1(30, Convert.ToInt32(this.pagenum), "topic.*,Category.Name", "order by Head desc,create_time desc", whereString, out num, "Category,topic");
        if (this.bbslist.Count == 0)
        {
            this.strpage = "对不起，没有相关数据";
        }
        else if (num >= 30)
        {
            this.strpage = topic.GetPublicBBsPageStr(num, Convert.ToInt32(this.pagenum), 30, this.ASNzY);
        }
    }

    public string Get_name(string ename)
    {
        Maticsoft.BLL.Category category = new Maticsoft.BLL.Category();
        return category.Get_name(this.Session["ename"].ToString());
    }

    public string Getbbs(string id)
    {
        string name = "";
        if ((id == null) || (id == ""))
        {
            name = "公共";
            this.falg = false;
            return name;
        }
        if (Utility.IsNum(base.Request["ASNzY"].ToString()))
        {
            Maticsoft.BLL.Category category = new Maticsoft.BLL.Category();
            Maticsoft.Model.Category model = new Maticsoft.Model.Category();
            model = category.GetModel(Convert.ToInt32(id));
            name = model.Name;
            this.bbsname = model.Name;
            this.ASNzY = base.Request["ASNzY"].ToString();
            this.falg = true;
            return name;
        }
        this.SetError("您输入的参数非法");
        return name;
    }

    public string Gettype(string id)
    {
        Maticsoft.BLL.Category category = new Maticsoft.BLL.Category();
        Maticsoft.Model.Category model = new Maticsoft.Model.Category();
        model = category.GetModel(Convert.ToInt32(id));
        if (model.Zone == "city")
        {
            return "本地";
        }
        return model.Name;
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        if (base.Request["pgnum"] != null)
        {
            if (Utility.IsNum(base.Request["pgnum"].ToString()))
            {
                this.pagenum = base.Request["pgnum"].ToString();
            }
            else
            {
                this.SetError("您输入的参数非法");
            }
        }
        this.Get_Bbs();
    }
}

